'use strict';
process.env.BABEL_ENV = 'production';
process.env.NODE_ENV = 'production';
const path = require('path');
const config = require('./config');
const fs = require('fs-extra');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.prod');

function build() {
    makeBuildEmpty();
    let compiler = webpack(webpackConfig);

    console.log("start webpack --config webpack.config.prod");
    compiler.run((err, stats) => {

    });
}
function makeBuildEmpty(){
    const deletePaths = [
        path.resolve(config.appDirectory,"view"),
        path.resolve(config.appDirectory,"js"),
        path.resolve(config.appDirectory,"image"),
        path.resolve(config.appDirectory,"css")
    ];
    deletePaths.forEach((item)=>{
        fs.emptyDirSync(item);
        console.log("delete path : ", item);
    })
}
build();
